package cn.ly.net.pic;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;
import java.net.UnknownHostException;

public class UploadClient {
	
	public static void main(String[] args) throws UnknownHostException, IOException {
		Socket s = new Socket("192.168.0.103",19199);
		
		//封装图片文件
		BufferedInputStream bis = new BufferedInputStream(
				new FileInputStream("C:\\Documents and Settings\\liuyu\\桌面\\Water lilies.jpg"));
		BufferedOutputStream bos = new BufferedOutputStream(s.getOutputStream());
		
		byte[] bys = new byte[1024];
		int len = 0;
		while( (len = bis.read(bys)) != -1){
			bos.write(bys, 0, len);
			
		}
		bos.flush();
		
		
		s.shutdownOutput();
		
		InputStream in = s.getInputStream();
		bys = new byte[1024];
		len = in.read(bys);
		System.out.println(new String(bys,0,len));
		
		s.close();
		
	}

}
